package cn.wps.moffice.common.infoflow.internal.cards.template; import android.app.LoaderManager; import android.content.Context; import android.content.Loader; import android.content.res.Configuration; import android.graphics.Bitmap; import android.os.Bundle; import android.text.TextPaint; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.widget.AbsListView; import android.widget.AdapterView; import android.widget.ImageView; import android.widget.ListAdapter; import android.widget.RelativeLayout; import android.widget.TextView; import cn.wps.moffice.cntemplate.bean.TemplateBean; import cn.wps.moffice.common.beans.CircleImageView; import cn.wps.moffice.common.beans.CommonErrorPage; import cn.wps.moffice.main.common.viewcontrols.ViewTitleBar; import cn.wps.moffice.main.framework.BaseActivity; import cn.wps.moffice.main.local.filebrowser.search.show.FilterPopup; import cn.wps.moffice.templatecommon.ext.widget.PageGridView; import cn.wps.moffice_eng.R; import com.appsflyer.AppsFlyerProperties; import com.fasterxml.jackson.core.util.MinimalPrettyPrinter; import com.google.firebase.analytics.FirebaseAnalytics; import com.google.gson.reflect.TypeToken; import com.mopub.mobileads.VastIconXmlManager; import com.mopub.nativeads.MoPubNativeAdPositioning; import defpackage.cup; import defpackage.dsa; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; public class TemplateAuthorActivity extends BaseActivity implements View.OnClickListener, AbsListView.OnScrollListener, AdapterView.OnItemClickListener, FilterPopup.b, PageGridView.c, cup.n, fys { private cuc cAj; private int cBX; private boolean cEC; private csx cET; private int cEU = 0; private String edM; private AuthorAboutInfo edN; private boolean edO; private String edP = "android_preview"; private String edQ = "preview_designer"; private PageGridView edR; private Set<Integer> edS; boolean edT; private ImageView edU; private ImageView edV; private RelativeLayout edW; private FilterPopup edX; private TextView edY; private TextView edZ; private TextView eea; private TextView eeb; private TextView eec; private TextView eed; private TextView eee; private dub eef; private int eeg; private RelativeLayout eeh; private View eei; private RelativeLayout eej; private RelativeLayout eek; private RelativeLayout eel; private RelativeLayout eem; private View mContentView; private CommonErrorPage mNoNetworkView; private String mPosition; private ViewTitleBar mTitleBar; /* access modifiers changed from: private */ /* access modifiers changed from: public */ private void a(int i, int i2, String str, String str2) { aMq(); if (!TextUtils.isEmpty(this.edM)) { getLoaderManager().restartLoader(52, null, new LoaderManager.LoaderCallbacks<ctq>(this, this.edM, this.cEU, i, i2, str, str2, this) { /* class defpackage.cup.AnonymousClass8 */ final /* synthetic */ n cCM; final /* synthetic */ String cCO; final /* synthetic */ int cCP; final /* synthetic */ int cCQ; final /* synthetic */ int cCR; final /* synthetic */ String cCS; final /* synthetic */ String cCT; final /* synthetic */ Context val$context; { this.val$context = r1; this.cCO = r2; this.cCP = r3; this.cCQ = r4; this.cCR = r5; this.cCS = r6; this.cCT = r7; this.cCM = r8; } @Override // android.app.LoaderManager.LoaderCallbacks public final Loader<ctq> onCreateLoader(int i, Bundle bundle) { Context context = this.val$context; String str = this.cCO; int i2 = this.cCP; int i3 = this.cCQ; int i4 = this.cCR; String str2 = this.cCS; return new log(context.getApplicationContext()).HX("https://docer.wps.cn/v3.php/api/android/mb/author/mb").b(new TypeToken<ctq>() { /* class defpackage.cup.AnonymousClass19 */ }.getType()).eU("author_id", str).eU(VastIconXmlManager.OFFSET, new StringBuilder().append(i2).toString()).eU("del_img_scale", "1").eU("file_type", "1").eU("orderby", str2).eU("mb_app", new StringBuilder().append(i3).toString()).eU("mb_type", new StringBuilder().append(i4).toString()).eU("order_direction", this.cCT).eT("X-Requested-With", "XMLHttpRequest"); } /* JADX DEBUG: Method arguments types fixed to match base method, original types: [android.content.Loader, java.lang.Object] */ @Override // android.app.LoaderManager.LoaderCallbacks public final /* synthetic */ void onLoadFinished(Loader<ctq> loader, ctq ctq) { ctq ctq2 = ctq; if (this.cCM != null) { if (!(ctq2 == null || ctq2.czy == null)) { gnb.bB(ctq2.czy.czA); } this.cCM.a(ctq2); } } @Override // android.app.LoaderManager.LoaderCallbacks public final void onLoaderReset(Loader<ctq> loader) { } }); } } private void a(TextView textView, String str, int i, List<FilterPopup.a> list) { textView.setText(str); if (!(list == null || list.isEmpty())) { for (FilterPopup.a aVar : list) { aVar.ePK = false; } list.get(2).ePK = true; } } static /* synthetic */ void a(TemplateAuthorActivity templateAuthorActivity, Bitmap bitmap) { Bitmap a = huw.a(templateAuthorActivity, bitmap, 30); Bitmap d = dub.d(a, (int) luf.bw(templateAuthorActivity), templateAuthorActivity.getResources().getDimensionPixelSize(R.dimen.home_docer_designer_author_background_height)); Bitmap m = templateAuthorActivity.eef.m(d); templateAuthorActivity.edU.setImageBitmap(d); templateAuthorActivity.edV.setImageBitmap(m); templateAuthorActivity.eef.egT = a; } private synchronized void a(ArrayList<TemplateBean> arrayList, ctq ctq) { int numColumns; int count; boolean z = false; synchronized (this) { this.cET.aui(); int size = (ctq == null || ctq.czy == null || ctq.czy.czA == null) ? 0 : ctq.czy.czA.size(); if (arrayList != null && size >= 20) { z = true; } this.edR.c(z, arrayList); if (z && (count = this.cET.getCount() % (numColumns = getNumColumns())) > 0) { this.cET.nC(numColumns - count); } if (!z) { this.cEU -= 20; } this.cEU += 20; } } private void a(boolean z, int i, List<FilterPopup.a> list, TextView textView, TextView textView2) { String str = list.get(i).heC; textView.setText(str); textView2.setText(str); if (z) { dub dub = this.eef; if (!TextUtils.isEmpty(str)) { if (str.equals(dub.egP)) { dub.egL = 1; } else if (str.equals(dub.egQ)) { dub.egL = 2; } else if (str.equals(dub.egR)) { dub.egL = 3; } else if (str.equals(dub.egS)) { dub.egL = 0; } } } else { dub dub2 = this.eef; String str2 = list.get(i).heB; if (TextUtils.isEmpty(str2)) { dub2.egN = "hot"; } else { dub2.egN = str2; } dub dub3 = this.eef; String str3 = list.get(i).egO; if (TextUtils.isEmpty(str3)) { dub3.egO = "desc"; } else { dub3.egO = str3; } this.eef.egM = list.get(i).egM; } this.eef.egU = true; this.edR.setHasMoreItems(true); PageGridView pageGridView = this.edR; if (pageGridView.mLoadinView != null) { int visibility = pageGridView.mLoadinView.getVisibility(); if (pageGridView.cSA.size() > 0) { pageGridView.removeFooterView(pageGridView.mLoadinView); } pageGridView.mLoadinView = (ViewGroup) LayoutInflater.from(pageGridView.getContext()).inflate(pageGridView.ohu, (ViewGroup) pageGridView, false); pageGridView.addFooterView(pageGridView.mLoadinView); pageGridView.mLoadinView.setVisibility(visibility); } cuh.clear(52); this.cEU = 0; if (this.eeh != null && this.eeh.getVisibility() == 0) { this.eeh.setVisibility(8); } a(this.eef.egL, this.eef.egM, this.eef.egN, this.eef.egO); } private void aMp() { int numColumns = getNumColumns(); if (this.edR != null) { this.edR.setNumColumns(numColumns); this.cET.cxO = getNumColumns(); } } private void aMq() { if (lwd.hu(this)) { if (this.mNoNetworkView.getVisibility() != 8) { this.mNoNetworkView.setVisibility(8); } } else if (this.mNoNetworkView.getVisibility() != 0) { this.mNoNetworkView.setVisibility(0); } } private int getNumColumns() { boolean z = getResources().getConfiguration().orientation == 2; return !this.cEC ? z ? 4 : 3 : z ? 3 : 2; } @Override // defpackage.cup.n public final void a(ctq ctq) { if (this.eef.egU) { if (this.eeg > getNumColumns() * 2) { this.edR.smoothScrollToPositionFromTop(getNumColumns() * 2, 0, 0); } ListAdapter wrappedAdapter = ((loi) this.edR.getAdapter()).getWrappedAdapter(); if (wrappedAdapter instanceof loh) { ((loh) wrappedAdapter).cZx(); } this.eef.egU = false; if (ctq == null || ctq.czy == null || ctq.czy.czA == null || ctq.czy.czA.isEmpty()) { this.eeh.setVisibility(0); } } if (ctq != null && ctq.czy != null) { ctq a = cuh.a(52, ctq, (int) MoPubNativeAdPositioning.MoPubClientPositioning.NO_REPEAT); a(cuh.a(a, true), ctq); if (this.eef.egL == 0) { this.eee.setText(getString(R.string.template_author_design_num) + MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR + a.czy.czz); } } } @Override // cn.wps.moffice.templatecommon.ext.widget.PageGridView.c public final void auX() { if (!this.eef.egU) { a(this.eef.egL, this.eef.egM, this.eef.egN, this.eef.egO); } } /* access modifiers changed from: protected */ @Override // cn.wps.moffice.main.framework.BaseActivity public fys createRootView() { return this; } /* access modifiers changed from: protected */ @Override // cn.wps.moffice.main.framework.BaseActivity public void createView() { super.createView(); } @Override // defpackage.fys public View getMainView() { if (this.eef == null) { this.eef = new dub(this); } if (this.mContentView == null) { Bundle extras = getIntent().getExtras(); if (extras != null) { this.edM = extras.getString("author_id"); this.edN = (AuthorAboutInfo) extras.getParcelable("author"); this.cBX = extras.getInt("template_type"); this.edO = extras.getBoolean("is_from_docer"); this.mPosition = extras.getString("position"); String string = extras.getString(AppsFlyerProperties.CHANNEL); String string2 = extras.getString("subchannel"); if (!TextUtils.isEmpty(string)) { this.edP = string; } if (!TextUtils.isEmpty(string2)) { this.edQ = string2; } } LayoutInflater from = LayoutInflater.from(this); View inflate = from.inflate(R.layout.public_template_author_home_page_layout, (ViewGroup) null); this.eei = from.inflate(R.layout.public_template_author_home_page_header_layout, (ViewGroup) null); this.mTitleBar = (ViewTitleBar) inflate.findViewById(R.id.titlebar); this.mTitleBar.setStyle(3); this.mTitleBar.setTitleText(R.string.template_author_home_page); this.mTitleBar.setCustomBackOpt(new Runnable() { /* class cn.wps.moffice.common.infoflow.internal.cards.template.TemplateAuthorActivity.AnonymousClass1 */ public final void run() { TemplateAuthorActivity.this.onBackPressed(); } }); this.edR = (PageGridView) inflate.findViewById(R.id.templates_grid); this.edW = (RelativeLayout) inflate.findViewById(R.id.template_sort); this.mNoNetworkView = (CommonErrorPage) inflate.findViewById(R.id.designer_no_network); this.edV = (ImageView) inflate.findViewById(R.id.designer_title_bg); this.mNoNetworkView.a(new View.OnClickListener() { /* class cn.wps.moffice.common.infoflow.internal.cards.template.TemplateAuthorActivity.AnonymousClass2 */ public final void onClick(View view) { TemplateAuthorActivity.this.a((TemplateAuthorActivity) TemplateAuthorActivity.this.eef.egL, TemplateAuthorActivity.this.eef.egM, (int) TemplateAuthorActivity.this.eef.egN, TemplateAuthorActivity.this.eef.egO); } }); View view = this.eei; this.eee = (TextView) view.findViewById(R.id.author_design_num); this.edU = (ImageView) view.findViewById(R.id.gaosi_img); this.edR.addHeaderView(view); View inflate2 = from.inflate(R.layout.public_template_author_home_page_sort_layout, (ViewGroup) null); View inflate3 = from.inflate(R.layout.public_template_author_home_page_sort_layout, (ViewGroup) null); View findViewById = inflate3.findViewById(R.id.sort_content); View findViewById2 = inflate3.findViewById(R.id.gray_divide_line); findViewById.setVisibility(8); findViewById2.setVisibility(0); this.edR.addHeaderView(inflate3); this.edR.addHeaderView(inflate2); this.edY = (TextView) inflate2.findViewById(R.id.type_sort_tv); this.edZ = (TextView) inflate2.findViewById(R.id.price_sort_tv); this.eea = (TextView) inflate2.findViewById(R.id.download_sort_tv); this.eej = (RelativeLayout) inflate2.findViewById(R.id.type_sort_tv_lay); this.eek = (RelativeLayout) inflate2.findViewById(R.id.download_sort_tv_lay); this.edY.setText(R.string.phone_home_new_search_all); this.edZ.setText(R.string.template_filter_price); this.eea.setText(R.string.template_filter_complex); this.edY.setOnClickListener(this); this.edZ.setOnClickListener(this); this.eea.setOnClickListener(this); this.eeh = (RelativeLayout) from.inflate(R.layout.public_designer_no_templates_layout, (ViewGroup) null); this.edR.addHeaderView(this.eeh); this.edR.setOnItemClickListener(this); this.cET = new csx(this, true, false, false); this.cET.cxN = R.layout.public_template_author_template_designer_item_layout; this.cET.cxM = true; this.cET.cxO = getNumColumns(); this.edR.setAdapter((ListAdapter) this.cET); this.edR.setNumColumns(getNumColumns()); this.edR.setPageLoadMoreListenerListener(this); this.edR.setOuterOnScrollListener(this); this.cAj = new cuc(inflate, "android_docervip_designer_tip", null); this.cAj.setPosition(this.mPosition); this.cAj.cBz = new Runnable() { /* class cn.wps.moffice.common.infoflow.internal.cards.template.TemplateAuthorActivity.AnonymousClass6 */ public final void run() { TemplateDetailDialog.bu(TemplateAuthorActivity.this); } }; this.cAj.cBA = new View.OnClickListener() { /* class cn.wps.moffice.common.infoflow.internal.cards.template.TemplateAuthorActivity.AnonymousClass7 */ public final void onClick(View view) { dwp.km("public_templates_designertip_click"); } }; dwp.km("public_templates_designertip_show"); aMp(); View view2 = this.eei; if (this.edN != null) { String qv = dty.qv(this.cBX); if (!TextUtils.isEmpty(qv) && !TextUtils.isEmpty(this.edN.name)) { dwp.at(qv + "_templates_designer_show", this.edN.name); } ((TextView) view2.findViewById(R.id.author_name)).setText(this.edN.name); if (!TextUtils.isEmpty(this.edN.ecF) && !this.edN.ecF.equalsIgnoreCase("null")) { final TextView textView = (TextView) view2.findViewById(R.id.author_desc); textView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { /* class cn.wps.moffice.common.infoflow.internal.cards.template.TemplateAuthorActivity.AnonymousClass3 */ public final void onGlobalLayout() { TextPaint paint = textView.getPaint(); paint.setTextSize(textView.getTextSize()); if (((int) paint.measureText(TemplateAuthorActivity.this.edN.ecF)) > (textView.getWidth() - textView.getPaddingLeft()) - textView.getPaddingRight()) { textView.setGravity(3); } else { textView.setGravity(17); } } }); textView.setText(this.edN.ecF); } CircleImageView circleImageView = (CircleImageView) view2.findViewById(R.id.author_icon); circleImageView.setBorderColor(getResources().getColor(R.color.white)); circleImageView.setBorderWidth(getResources().getDimensionPixelSize(R.dimen.home_docer_designer_author_border_width)); dsa li = dry.bt(getApplicationContext()).li(this.edN.ecE); li.dYN = ImageView.ScaleType.FIT_CENTER; li.dYL = false; li.dYK = R.drawable.template_author_default_avatar; li.dYM = true; li.a(circleImageView, new dsa.a() { /* class cn.wps.moffice.common.infoflow.internal.cards.template.TemplateAuthorActivity.AnonymousClass4 */ @Override // defpackage.dsa.a public final void a(String str, ImageView imageView, Bitmap bitmap) { if (bitmap != null && TemplateAuthorActivity.this.edU != null) { TemplateAuthorActivity.a(TemplateAuthorActivity.this, bitmap); } } }); } a(this.eef.egL, this.eef.egM, this.eef.egN, this.eef.egO); this.eeb = (TextView) inflate.findViewById(R.id.type_sort_tv); this.eec = (TextView) inflate.findViewById(R.id.price_sort_tv); this.eed = (TextView) inflate.findViewById(R.id.download_sort_tv); this.eel = (RelativeLayout) inflate.findViewById(R.id.type_sort_tv_lay); this.eem = (RelativeLayout) inflate.findViewById(R.id.download_sort_tv_lay); this.eeb.setText(R.string.phone_home_new_search_all); this.eec.setText(R.string.template_filter_price); this.eed.setText(R.string.template_filter_complex); this.eeb.setOnClickListener(this); this.eec.setOnClickListener(this); this.eed.setOnClickListener(this); this.mContentView = inflate; } return this.mContentView; } @Override // defpackage.fys public String getViewTitle() { return getResources().getString(R.string.template_author_home_page); } @Override // cn.wps.moffice.main.local.filebrowser.search.show.FilterPopup.b public final void h(View view, int i) { if (view == this.eej || view == this.eel) { a(true, i, this.eef.egI, this.edY, this.eeb); } else if (view == this.edZ || view == this.eec) { a(false, i, this.eef.egJ, this.edZ, this.eec); a(this.eea, getString(R.string.template_filter_complex), 2, this.eef.egK); a(this.eed, getString(R.string.template_filter_complex), 2, this.eef.egK); } else if (view == this.eek || view == this.eem) { a(false, i, this.eef.egK, this.eea, this.eed); a(this.edZ, getString(R.string.template_filter_price), 2, this.eef.egJ); a(this.eec, getString(R.string.template_filter_price), 2, this.eef.egJ); } } public void onClick(View view) { switch (view.getId()) { case R.id.download_sort_tv /*{ENCODED_INT: 2131362739}*/: if (this.edW.getVisibility() == 0) { this.edX.a(this.eem, this.eef.egK, this); return; } else { this.edX.a(this.eek, this.eef.egK, this); return; } case R.id.price_sort_tv /*{ENCODED_INT: 2131367038}*/: this.edX.a(view, this.eef.egJ, this); return; case R.id.type_sort_tv /*{ENCODED_INT: 2131368845}*/: if (this.edW.getVisibility() == 0) { this.edX.a(this.eel, this.eef.egI, this); return; } else { this.edX.a(this.eej, this.eef.egI, this); return; } default: return; } } @Override // cn.wps.moffice.common.beans.OnResultActivity, cn.wps.moffice.main.framework.BaseActivity public void onConfigurationChanged(Configuration configuration) { super.onConfigurationChanged(configuration); aMp(); if (this.eef.egT != null) { final Bitmap bitmap = this.eef.egT; this.edV.postDelayed(new Runnable() { /* class cn.wps.moffice.common.infoflow.internal.cards.template.TemplateAuthorActivity.AnonymousClass5 */ public final void run() { int bw = (int) luf.bw(TemplateAuthorActivity.this); int dimensionPixelSize = TemplateAuthorActivity.this.getResources().getDimensionPixelSize(R.dimen.home_docer_designer_author_background_height); dub unused = TemplateAuthorActivity.this.eef; Bitmap d = dub.d(bitmap, bw, dimensionPixelSize); Bitmap m = TemplateAuthorActivity.this.eef.m(d); TemplateAuthorActivity.this.edU.setImageBitmap(d); TemplateAuthorActivity.this.edV.setImageBitmap(m); } }, 50); } } /* access modifiers changed from: protected */ @Override // cn.wps.moffice.common.beans.OnResultActivity, cn.wps.moffice.main.framework.BaseActivity public void onCreate(Bundle bundle) { this.cEC = luf.gQ(this); super.onCreate(bundle); if (this.edO) { setRequestedOrientation(1); } cuh.clear(52); this.edX = new FilterPopup(); } /* access modifiers changed from: protected */ @Override // cn.wps.moffice.common.beans.OnResultActivity, cn.wps.moffice.main.framework.BaseActivity public void onDestroy() { super.onDestroy(); this.cAj.cBz = null; cuh.clear(52); if (getLoaderManager() != null) { getLoaderManager().destroyLoader(52); } } @Override // android.widget.AdapterView.OnItemClickListener public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) { String str = null; cup.a(this, (TemplateBean) this.edR.getItemAtPosition(i), "android_credits_docermall", "android_docervip_docermall", null, null, this.edO, this.mPosition, this.edP, this.edQ); String qv = dty.qv(this.cBX); if (!TextUtils.isEmpty(qv) && !TextUtils.isEmpty(this.edN.name)) { String str2 = qv + "_templates_designer_click"; StringBuilder append = new StringBuilder().append(this.edN.name).append(" type:"); dub dub = this.eef; switch (dub.egL) { case 0: str = dub.egS; break; case 1: str = dub.egP; break; case 2: str = dub.egQ; break; case 3: str = dub.egR; break; } StringBuilder append2 = append.append(str).append(" orderby:"); dub dub2 = this.eef; dwp.at(str2, append2.append(FirebaseAnalytics.Param.PRICE.equals(dub2.egN) ? dub2.egN + MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR + dub2.egO : dub2.egN).toString()); } } @Override // cn.wps.moffice.common.beans.CountDisplayTimeActivity, cn.wps.moffice.common.beans.OnResultActivity, cn.wps.moffice.main.framework.BaseActivity public void onResume() { super.onResume(); this.cAj.refresh(); aMq(); } public void onScroll(AbsListView absListView, int i, int i2, int i3) { if (this.edS == null) { this.edS = new HashSet(); } if (this.edT) { this.edS.clear(); } else { String qv = dty.qv(this.cBX); for (int i4 = i; i4 < i + i2; i4++) { if (i4 < i3 && ((TemplateBean) this.edR.getAdapter().getItem(i4)) != null && !this.edS.contains(Integer.valueOf(i4))) { dwp.at(qv + "_templates_designer_show", this.edN.name); } } this.edS.clear(); for (int i5 = i; i5 < i + i2; i5++) { if (i5 < i3 && ((TemplateBean) this.edR.getAdapter().getItem(i5)) != null) { this.edS.add(Integer.valueOf(i5)); } } } if (i >= getNumColumns() * 2) { this.edW.setVisibility(0); } else { this.edW.setVisibility(8); } this.eeg = i; } public void onScrollStateChanged(AbsListView absListView, int i) { if (i == 2) { this.edT = true; } else { this.edT = false; } } }